/*                   _   _ _ __                               *\
**     ________ ___ | | | | '_ \   scaup - Scala up!          **
**    / __/ __// _ || | | | |_) |  (c) 2008, Normen Mueller   **
**  __\ \/ /__/ __ || |_| | .__/   http://kwarc.info.nmueller **
** /____/\___/_/ |_/ \__,_|_|                                 **
**                                                            **
\*                                                            */
  
// $Id$

/* This class has its origin at: scala.tools.nsc.Properties */

package scaup

/** A utility to load the properties from a Java properties file included in the jar.
 * 
 * @param propFilename the name of the properties file
 * 
 * @author Normen M&uuml;ller */
class Properties(propFilename: String) {

  /** The loaded properties */
  private val props = {
    val props = new java.util.Properties
    val stream = classOf[Properties].getResourceAsStream(propFilename)
    if (stream != null)
      props.load(stream)
    props
  }

  val isWin = System.getProperty("os.name") startsWith "Windows"

  /** The version number of the jar this was loaded from, or "(unknown)" if it cannot be determined. */
  val versionString: String = {
    val defaultString = "(unknown)"
    "version " + props.getProperty("version.number", defaultString)
  }
  
  val copyrightString: String = {
    val defaultString = "(c) 2008 Normen Mueller"
    props.getProperty("copyright.string", defaultString)
  }

  val encodingString: String = {
    val defaultString = "UTF8" //"ISO-8859-1"
    props.getProperty("file.encoding", defaultString)
  }

  val envClasspath: String =
    System.getProperty("env.classpath")
}
